package {{packageName}}.sample.infrastructure.primary;

import dev.langchain4j.model.chat.ChatLanguageModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
class ChatResource {

  private final ChatLanguageModel chatLanguageModel;

  public ChatResource(ChatLanguageModel chatLanguageModel) {
    this.chatLanguageModel = chatLanguageModel;
  }

  @GetMapping("/chat")
  public String send(@RequestParam(value = "message", defaultValue = "Hello") String message) {
    return chatLanguageModel.generate(message);
  }
}
